package com.xbongbong.saas.script.tempenum;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.constant.TimeConstant;
import com.xbongbong.paas.enums.DateTimeEnum;
import com.xbongbong.paas.enums.DefaultTypeEnum;
import com.xbongbong.paas.field.DefaultAttrPoJo;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.LinkDetailPojo;
import com.xbongbong.paas.field.NumericalLimitsPoJo;
import com.xbongbong.pro.enums.AmountFlagEnum;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.paas.field.SaasParticularAttributePoJo;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.constant.StringConstant;
import com.xbongbong.saas.enums.ForbiddenSettingEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.FundTransferEnum;
import com.xbongbong.saas.enums.dictionary.PayMethodEnum;
import com.xbongbong.saas.script.help.InitExplainsHelper;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author zcp
 * @version v1.0
 * @since v1.0
 */
@Getter
public enum TempFundTransferEnum {
    //刷脚本专用枚举
    BASE_INFO(FundTransferEnum.BASE_INFO),
    SHEET_NO(FundTransferEnum.SHEET_NO),
    AMOUNT(FundTransferEnum.AMOUNT),
    BELONG_ID(FundTransferEnum.BELONG_ID),
    TRANSFER_TIME(FundTransferEnum.TRANSFER_TIME),
    OUT_FUND_ACCOUNT(FundTransferEnum.OUT_FUND_ACCOUNT),
    IN_FUND_ACCOUNT(FundTransferEnum.IN_FUND_ACCOUNT),
    PAY_METHOD(FundTransferEnum.PAY_METHOD),
    SYSTEM_INFO(FundTransferEnum.SYSTEM_INFO),
    MEMO(FundTransferEnum.MEMO),
    FILE(FundTransferEnum.FILE),
    CREATOR_ID(FundTransferEnum.CREATOR_ID),
    ADD_TIME(FundTransferEnum.ADD_TIME),
    UPDATE_TIME(FundTransferEnum.UPDATE_TIME),

    ;
    private FundTransferEnum anEnum;

    TempFundTransferEnum(FundTransferEnum anEnum) {
        this.anEnum = anEnum;
    }

    public static List<TempFundTransferEnum> getAllEnum() {
        List<TempFundTransferEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }

    public static void initSheetNo(FieldAttrEntity fieldAttrEntity) {
        LinkDetailPojo linkDetailPojo = new LinkDetailPojo();
        linkDetailPojo.setBusinessType(XbbRefTypeEnum.FUND_TRANSFER.getCode());
        linkDetailPojo.setSubBuisenssType(XbbRefTypeEnum.FUND_TRANSFER.getCode());
        linkDetailPojo.setSaasMark(SaasMarkEnum.SAAS.getCode());
        linkDetailPojo.setAttr(SHEET_NO.getAnEnum().getAttr());
        fieldAttrEntity.setLinkDetail(linkDetailPojo);
        fieldAttrEntity.setNoRepeat(1);
        fieldAttrEntity.setSerialNumber(InitExplainsHelper.setSerialNumber(SerialNumberEnum.FUND_TRANSFER_NO));
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setShowAttrPermission(BasicConstant.ZERO);
    }

    public static void initAmount(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setSummaryFlag(1);
        fieldAttrEntity.setAmountFlag(AmountFlagEnum.YES.getType());
        fieldAttrEntity.setIsForbidden(0);
        //不允许修改默认值
        fieldAttrEntity.setItemBanDefault(BasicConstant.ONE);
        fieldAttrEntity.setForbiddenSettingList(Collections.singletonList(ForbiddenSettingEnum.DISABLE_DEFAULT.getAlias()));
        NumericalLimitsPoJo numericalLimits = new NumericalLimitsPoJo();
        numericalLimits.setMin(0D);
        numericalLimits.setMax(100000000000D);
        fieldAttrEntity.setNumericalLimits(numericalLimits);
        fieldAttrEntity.setNumericalLimitsFlag(1);
    }

    public static void initBelongId(FieldAttrEntity fieldAttrEntity) {
        DefaultAttrPoJo defaultAttrPoJo = new DefaultAttrPoJo();
        defaultAttrPoJo.setDefaultType(DefaultTypeEnum.DYNAMIC.getAlias());
        defaultAttrPoJo.setDefaultValue("0");
        fieldAttrEntity.setDefaultAttr(defaultAttrPoJo);
        fieldAttrEntity.setIsForbidden(0);
    }

    public static void initTransferTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setDateType( DateTimeEnum.TIME.getType());
        DefaultAttrPoJo defaultAttrPoJo = new DefaultAttrPoJo();
        defaultAttrPoJo.setDefaultType("today");
        defaultAttrPoJo.setDefaultValue("");
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setPeriodLimitType(true);
        saasParticularAttributePoJo.setDay(TimeConstant.MONTH);
        fieldAttrEntity.setDefaultAttr(defaultAttrPoJo);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
    }

    public static void initOutFundAccount(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setDictionaryFlag(BasicConstant.TWO);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setNoItemLink(BasicConstant.ONE);
        fieldAttrEntity.setItemBanDefault(BasicConstant.ONE);
        fieldAttrEntity.setShowAttrPermission(BasicConstant.ZERO);
        fieldAttrEntity.setMemo("账户信息可在【管理中心-其他设置-资金账户】中自定义修改");
    }

    public static void initInFundAccount(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setDictionaryFlag(BasicConstant.TWO);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setNoItemLink(BasicConstant.ONE);
        fieldAttrEntity.setItemBanDefault(BasicConstant.ONE);
        fieldAttrEntity.setShowAttrPermission(BasicConstant.ZERO);
        fieldAttrEntity.setMemo("账户信息可在【管理中心-其他设置-资金账户】中自定义修改");
    }

    public static void initPayMethod(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setItems(InitExplainsHelper.setCombItemByEnum(PayMethodEnum.class, fieldAttrEntity.getFieldType()));
        fieldAttrEntity.setDictionaryFlag(1);
    }

    public static void initCreatorId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }
    public static void initAddTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }
    public static void initUpdateTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }
}
